

cd "${data}"
use "1999-2019_CHES_dataset_means(v3).dta", clear


keep country eu_position lrgen lrecon galtan spendvtax deregulation redistribution econ_interven civlib_laworder sociallifestyle immigrate_policy environment electionyear year vote party govt party_id 

keep if country==13 | country==1 | country==20 | country==31 | country==40 | country==21 | country==2 | country==22 | country==14 | country==6 | country==3 | country==4 | country==23 | country==7 | country==8| country==24 | country==25 | country==38 | country==37 | country==10 | country==26 | country==12 | country==27 | country==28 | country==29 | country==5 | country==16 | country==11 



/*
missing elections to determine the ideology of the government before past turnout in ESS:
Denmark 2015
Spaın 2015 and Spain 2016
portugal 2015
finland 2015
slovenia 2011
bulgaria 2014
czech 2013
estonia 2015
poland 2015
sweden 2014
croatia 2007
malta 2008
luxembourg 2009
cyprus 2006
*/


gen governmentparties_t1 = ""
replace governmentparties_t1 ="Belgium_2014" if year==2010 & country==1 // ok
replace governmentparties_t1 ="Belgium_2019" if year==2014 & country==1 // ok
replace governmentparties_t1 ="Denmark_2014" if year==2010 & country==2 // ok
replace governmentparties_t1 ="Denmark_2019" if year==2014 & country==2 // ok
replace governmentparties_t1 ="Germany_2014" if year==2010 & country==3 // ok
replace governmentparties_t1 ="Germany_2019" if year==2014 & country==3 // ok
replace governmentparties_t1 ="Greece_2014" if year==2010 & country==4 // ok
replace governmentparties_t1 ="Greece_2019" if year==2014 & country==4 // assign greece 2015 elections which is not in the data yet. Governing party is syriza (with support from independent greeks)
		replace govt = . if year==2014 & country==4 
		replace govt = 1 if year==2014 & country==4 & party == "ANEL"
		replace govt = 1 if year==2014 & country==4 & party == "SYRIZA"
		replace vote = . if year==2014 & country==4
		replace vote = 35.5 if year==2014 & country==4 & party == "SYRIZA"
		replace vote = 3.7 if year==2014 & country==4 & party == "ANEL"

replace governmentparties_t1 ="Spain_2014" if year==2010 & country==5 // ok
replace governmentparties_t1 ="Spain_2019" if year==2019 & country==5 // assign spain 2016 election which is not in the data yet. ATTENTION TO THIS ONE. FIRST RIGHT RULED THEN LEFT CONSEQUENTLY BUT LEFT WAS IN PLACE DURING THE ELECTION TIME. 
		replace govt = . if year==2019 & country==5 
		* replace govt = 1 if year==2019 & country==5 & party == "PPP" // first 2 years
		replace govt = 1 if year==2019 & country==5 & party == "PSOE" // last 10 months 
		replace vote = . if year==2019 & country==5
		replace vote = 22.7 if year==2019 & country==5 & party == "PSOE"

replace governmentparties_t1 = "France_2014" if year==2010 & country==6 // ok
replace governmentparties_t1 = "France_2019" if year==2014 & country==6 // ok
		replace govt = 1 if year==2014 & country==6 & party == "EELV" 
 
replace governmentparties_t1 = "Ireland_2014" if year==2010 & country==7 // ok
replace governmentparties_t1 = "Ireland_2019" if year==2014 & country==7 // ok
replace governmentparties_t1 = "Italy_2014" if year==2010 & country==8  // ok
replace governmentparties_t1 = "Italy_2019" if year==2014 & country==8 // ok
replace governmentparties_t1 = "Netherlands_2014" if year==2010 & country==10 // ok
replace governmentparties_t1 = "Netherlands_2019" if year==2014 & country==10 // ok
replace governmentparties_t1 = "United Kingdom_2014" if year==2006 & country==11 // ok
replace governmentparties_t1 ="United Kingdom_2019" if year==2014 & country==11 // assign uk 2015 election whuch is not in the data yet.
		replace govt = . if country==11 & year==2014 
		replace govt = 1 if country==11 & year==2014 & party=="CONS"
		replace vote = . if country==11 & year==2014 
		replace vote = 37 if country==11 & year==2014 & party=="CONS"

replace governmentparties_t1 ="Portugal_2014" if year==2010 & country==12 // ok
replace governmentparties_t1 ="Portugal_2019" if year==2014 & country==12 // assign portugal 2015 election whuch is not in the data yet
		replace govt = . if country==12 & year==2014 
		replace govt = 1 if country==12 & year==2014 & party=="PS"
		replace vote = . if country==12 & year==2014 
		replace vote = 33.6 if country==12 & year==2014 & party=="PS"

replace governmentparties_t1 ="Austria_2014" if year==2010 & country==13 // ok
replace governmentparties_t1 ="Austria_2019" if year==2014 & country==13 // ok
replace governmentparties_t1 ="Finland_2014" if year==2010 & country==14 // ok
replace governmentparties_t1 ="Finland_2019" if year==2014 & country==14 // assign fin 2015
		replace govt = . if country==14 & year==2014 
		replace govt = 1 if country==14 & year==2014 & party=="KESK"
		replace govt = 1 if country==14 & year==2014 & party=="KOK"
		replace govt = 1 if country==14 & year==2014 & party=="PS" // True finns, there was a split from this party in the middle, who stayed in government and true fins was then no longer in government. 
		replace vote = . if country==14 & year==2014 
		replace vote = 21.1 if country==14 & year==2014 & party=="KESK"
		replace vote = 18.2 if country==14 & year==2014 & party=="KOK"
		replace vote =  17.5 if country==14 & year==2014 & party=="PS"
		
replace governmentparties_t1 ="Sweden_2014" if year==2010 & country==16 // ok
replace governmentparties_t1 ="Sweden_2019" if year==2014 & country==16 // adjustment needed: in-government parties after 2014 elections (in place before 2019 elections) are SAP and MP. 
		replace govt = . if country==16 & year==2014 
		replace govt = 1 if country==16 & year==2014 & party=="SAP"
		replace govt = 1 if country==16 & year==2014 & party=="MP"
		replace govt = 0 if country==16 & year==2014 & party=="C" 
		replace govt = 0 if country==16 & year==2014 & party=="FP"
		replace govt = 0 if country==16 & year==2014 & party=="SD"
		replace govt = 0 if country==16 & year==2014 & party=="V"
		replace govt = 0 if country==16 & year==2014 & party=="PIRAT"
		replace govt = 0 if country==16 & year==2014 & party=="M" 
		replace govt = 0 if country==16 & year==2014 & party=="FI" 
		replace govt = 0 if country==16 & year==2014 & party=="KD" 

		replace vote = . if country==16 & year==2014 
		replace vote = 31 if country==16 & year==2014 & party=="SAP"
		replace vote = 4.4 if country==16 & year==2014 & party=="MP"


replace governmentparties_t1 ="Bulgaria_2014" if year==2010 & country==20 // ok (last one year was caretaking government, but before that GERB ruled)

		* for "Bulgaria_2019"// adjustment needed: last election is 2017, so the last turnout is about 2017 elections. Before that the following cabinet was in place for more than 2 years: 1) ABV-Alternativa za balgarsko vazrazhdane 2) GERB-Grazhdani za Evropeysko Razvitie na Balgariya 3) RB Reformatorski Blok
		
replace governmentparties_t1 ="Bulgaria_2019" if year==2019 & country==20 
		replace govt = . if country==20 & year==2019
		replace govt = 1 if country==20 & year==2019 & party=="GERB" 
* take ABV from 2014 and add the obs to 2019 as government party 
		replace vote = . if country==20 & year==2019
		replace vote = 32.7 if country==20 & year==2019 & party=="GERB" 

replace governmentparties_t1 ="Czech Republic_2014" if year==2010 & country==21  // ok // last three months prior to the election was a caretaker government, but I assign the previous coalition TOP09, VV and ODS (note that VV was only a part of this coalition for two years, then it was out for the last year.)

* "Czech Republic_2019" adjustment needed: vote share is ok.
replace governmentparties_t1 ="Czech Republic_2019" if year==2014 & country==21 
		replace govt = . if country==21 & year==2014 
		replace govt = 1 if country==21 & year==2014 & party=="ANO2011"
		replace govt = 1 if country==21 & year==2014 & party=="CSSD"
		replace govt = 1 if country==21 & year==2014 & party=="KDU-CSL"  
		
replace governmentparties_t1 ="Estonia_2014" if year==2010 & country==22 // vote share is ok
		replace govt = . if country==22 & year==2010
		replace govt = 1 if country==22 & year==2010 & party=="ER"
		replace govt = 1 if country==22 & year==2010 & party=="IRL"
		replace govt = 0 if country==22 & year==2010 & party=="EK"
		replace govt = 0 if country==22 & year==2010 & party=="EER"
		replace govt = 0 if country==22 & year==2010 & party=="ERL"
		replace govt = 0 if country==22 & year==2010 & party=="SDE"		
replace governmentparties_t1 ="Estonia_2019" if year==2019 & country==22 // assign estonia 2015 which is not in the data yet 
		replace govt = . if country==22 & year==2019
		replace govt = 1 if country==22 & year==2019 & party=="EK" 
		replace govt = 1 if country==22 & year==2019 & party=="IRL"
		replace govt = 1 if country==22 & year==2019 & party=="SDE"
		replace vote = . if country==22 & year==2019
		replace vote = 24.8 if country==22 & year==2019 & party=="EK" 
		replace vote = 13.7 if country==22 & year==2019 & party=="IRL"
		replace vote = 15.2 if country==22 & year==2019 & party=="SDE"
	
		
replace governmentparties_t1 ="Hungary_2014" if year==2010 & country==23 // ok
replace governmentparties_t1 ="Hungary_2019" if year==2014 & country==23 // ok
replace governmentparties_t1 ="Latvia_2014" if year==2010 & country==24  // adjustment 
*adjustment needed for government parties: 
		replace govt = . if country==24 & year==2010
		replace govt = 1 if country==24 & year==2010 & party=="NA"
		replace govt = 1 if country==24 & year==2010 & party=="ZRP"
		replace govt = 1 if country==24 & year==2010 & party=="ZZS"
		replace govt = 1 if country==24 & year==2010 & party=="V"
		replace govt = 0 if country==24 & year==2010 & party=="SC"	
replace governmentparties_t1 ="Latvia_2019" if year==2014 & country==24 // adjustment. vote share is ok 
		replace govt = 1 if country==24 & year==2014 & party=="ZZS"	
replace governmentparties_t1 ="Lithuania_2014" if year==2010 & country==25 // adjustment 
		replace govt = 1 if country==25 & year==2010 & party=="LiCS"
replace governmentparties_t1 ="Lithuania_2019" if year==2014 & country==25 //ok
replace governmentparties_t1 ="Poland_2014" if year==2010 & country==26 // ok
replace governmentparties_t1 ="Poland_2019" if year==2019 & country==26 // assign poland 2015 which is not in data yet: it is the same, so leave it as PIS. Adjust the vote share. 
		replace vote = . if country==26 & year==2019
		replace vote = 37.6 if country==26 & year==2019 & party=="PiS"	


replace governmentparties_t1 ="Romania_2014" if year==2010 & country==27 // TOTAL CHAOS HERE. 1ST YEAR IS PDL AND PSD COALITION. PDL UDMR FOR ANOTHER HALF YEAR.  THEN PDL  UDMR AND UNPR COALITION FOR TWO YEARS. 7 MONTHS A COALITION OF PNL PSD AND PU/PC. I will assign the last government. 
		replace govt = . if country==27 & year==2010
		replace govt = 1 if country==27 & year==2010 & party=="PC"
		replace govt = 1 if country==27 & year==2010 & party=="PSD"
		replace govt = 1 if country==27 & year==2010 & party=="PNL"

replace governmentparties_t1 ="Romania_2019" if year==2014 & country==27 // Assign 2016 elections. Change vote shares. AGAIN TOTAL CHAOS. I take those who participated in most of the governments. Last one year is a caretaker government anyway. 
		replace govt = . if country==27 & year==2014
		replace govt = 1 if country==27 & year==2014 & party=="PC"
		replace govt = 1 if country==27 & year==2014 & party=="PSD"
		replace vote = . if country==27 & year==2014
	*	replace vote = . if country==27 & year==2014 & party=="PC" // no vote share. and it is tiny party anyway 
		replace vote = 58.6 if country==27 & year==2014 & party=="PSD"	
		
replace governmentparties_t1 ="Slovakia_2014" if year==2010 & country==28 // ok 
replace governmentparties_t1 ="Slovakia_2019" if year==2014 & country==28 // ok  
replace governmentparties_t1 ="Slovenia_2014" if year==2010 & country==29 // ok
replace governmentparties_t1 ="Slovenia_2019" if year==2014 & country==29 // adjustment needed
		replace govt = 1 if country==29 & year==2014 & party=="SMC"
		replace govt = 0 if country==29 & year==2014 & party=="PS"
replace governmentparties_t1 ="Croatia_2014" if year==2014 & country==31 // assing croatia 2007 which is not in data yet 
		replace govt = . if country==31 & year==2014 
		replace govt = 1 if country==31 & year==2014 & party=="HDZ"
		replace govt = 1 if country==31 & year==2014 & party=="HSS"
		replace govt = 1 if country==31 & year==2014 & party=="HSLS"
		replace vote = . if country==31 & year==2014
		replace vote = 35.9 if country==31 & year==2014 & party=="HDZ"
		replace vote = 6.4 if country==31 & year==2014 & party=="HSS"
		* replace vote = . if country==31 & year==2014 & party=="HSLS" (no vote share info in parlgov)

		
replace governmentparties_t1 ="Croatia_2019" if year==2019 & country==31 // ADJUSTMENT 
		replace govt = . if country==31 & year==2019 
		replace govt = 1 if country==31 & year==2019 & party=="MOST"
		replace govt = 1 if country==31 & year==2019 & party=="HDZ"
		replace vote = . if country==31 & year==2019
		replace vote = 13.4 if country==31 & year==2019 & party=="MOST"
		replace vote = 34.1 if country==31 & year==2019 & party=="HDZ"

	
replace governmentparties_t1 ="Malta_2014" if year==2014 & country==37 // assign malta 2008
		replace govt = . if country==37 & year==2014
		replace govt = 1 if country==37 & year==2014 & party=="PN"
		replace vote = . if country==37 & year==2014
		replace vote = 39.4 if country==37 & year==2014 & party=="PN"
		
		
replace governmentparties_t1 ="Malta_2019" if year==2019 & country==37
		replace govt = . if country==37 & year==2019
		replace govt = 1 if country==37 & year==2019 & party=="PL"
	

replace governmentparties_t1 ="Luxembourg_2014" if year==2014 & country==38 // assign luxembourg 2009
		replace govt = . if country==38 & year==2014
		replace govt = 1 if country==38 & year==2014 & party=="LSAP"
		replace govt = 1 if country==38 & year==2014 & party=="CSV"
		
		
replace governmentparties_t1 ="Luxembourg_2019" if year==2019 & country==38 ///  YOU NEED TO DUPLICATE THESE FROM 2014 TO 2019. I took (below) the information from 2014 and pasted it to 2019 column. So, the info comes from 2012 election results.

		replace govt = . if country==38 & year==2019
		replace govt = 1 if country==38 & year==2019 & party=="LSAP"
		replace govt = 1 if country==38 & year==2019 & party=="CSV"
		replace govt = 1 if country==38 & year==2019 & party=="GRENG"
		
		replace lrgen = . if country==38 & year==2019 
		replace lrecon = . if country==38 & year==2019 
		replace galtan = . if country==38 & year==2019 
		replace spendvtax = . if country==38 & year==2019 
		replace deregulation = . if country==38 & year==2019 
		replace redistribution = . if country==38 & year==2019 
		replace econ_interven = . if country==38 & year==2019 
		replace civlib_laworder = . if country==38 & year==2019 
		replace sociallifestyle = . if country==38 & year==2019 
		replace immigrate_policy = . if country==38 & year==2019 
		replace environment = . if country==38 & year==2019 
		replace eu_position = . if country==38 & year==2019 

		replace lrgen = 4 if country==38 & year==2019 & party=="LSAP"
		replace lrecon = 4.5 if country==38 & year==2019 & party=="LSAP"
		replace galtan = 1 if country==38 & year==2019 & party=="LSAP"
		replace spendvtax = 5.5 if country==38 & year==2019 & party=="LSAP"
		replace deregulation = 5.5 if country==38 & year==2019 & party=="LSAP"
		replace redistribution = 2.5 if country==38 & year==2019 & party=="LSAP"
		replace econ_interven = 5.5 if country==38 & year==2019 & party=="LSAP"
		replace civlib_laworder = 2 if country==38 & year==2019 & party=="LSAP"
		replace sociallifestyle = 1 if country==38 & year==2019 & party=="LSAP"
		replace immigrate_policy = 6 if country==38 & year==2019 & party=="LSAP"
		replace environment = 6 if country==38 & year==2019 & party=="LSAP"
		replace eu_position = 6.33 if country==38 & year==2019 & party=="LSAP"

		replace lrgen = 6.5 if country==38 & year==2019 & party=="CSV"
		replace lrecon = 4.5 if country==38 & year==2019 & party=="CSV"
		replace galtan = 6 if country==38 & year==2019 & party=="CSV"
		replace spendvtax = 4.5 if country==38 & year==2019 & party=="CSV"
		replace deregulation = 6 if country==38 & year==2019 & party=="CSV"
		replace redistribution = 4.5 if country==38 & year==2019 & party=="CSV"
		replace econ_interven = 6 if country==38 & year==2019 & party=="CSV"
		replace civlib_laworder = 5 if country==38 & year==2019 & party=="CSV"
		replace sociallifestyle = 5.5 if country==38 & year==2019 & party=="CSV"
		replace immigrate_policy = 7.5 if country==38 & year==2019 & party=="CSV"
		replace environment = 5.5 if country==38 & year==2019 & party=="CSV"
		replace eu_position = 7 if country==38 & year==2019 & party=="CSV"

		replace lrgen = 3 if country==38 & year==2019 & party=="GRENG"
		replace lrecon = 4 if country==38 & year==2019 & party=="GRENG"
		replace galtan = 0.5 if country==38 & year==2019 & party=="GRENG"
		replace spendvtax = 6 if country==38 & year==2019 & party=="GRENG"
		replace deregulation = 5 if country==38 & year==2019 & party=="GRENG"
		replace redistribution = 4 if country==38 & year==2019 & party=="GRENG"
		replace econ_interven = 4.5 if country==38 & year==2019 & party=="GRENG"
		replace civlib_laworder = 2 if country==38 & year==2019 & party=="GRENG"
		replace sociallifestyle = 1 if country==38 & year==2019 & party=="GRENG"
		replace immigrate_policy = 4.5 if country==38 & year==2019 & party=="GRENG"
		replace environment = 1 if country==38 & year==2019 & party=="GRENG"
		replace eu_position = 6.33 if country==38 & year==2019 & party=="GRENG"

		replace vote = . if country==38 & year==2019
		replace vote = 20.3 if country==38 & year==2019 & party=="LSAP"
		replace vote = 33.7 if country==38 & year==2019 & party=="CSV"
		replace vote = 10.1 if country==38 & year==2019 & party=="GRENG"
		
		
replace governmentparties_t1 ="Cyprus_2014" if year==2014 & country==40 // assign cyprus 2006
		replace govt = . if country==40 & year==2014
		replace govt = 1 if country==40 & year==2014 & party=="AKEL"
		replace govt = 1 if country==40 & year==2014 & party=="DIKO"
		replace govt = 1 if country==40 & year==2014 & party=="EDEK"
 		replace vote = . if country==40 & year==2014
		replace vote = 31.1 if country==40 & year==2014 & party=="AKEL"
		replace vote = 17.9 if country==40 & year==2014 & party=="DIKO"
		replace vote = 8.9 if country==40 & year==2014 & party=="EDEK"

replace governmentparties_t1 ="Cyprus_2019" if year==2019 & country==40 // use the info thaat corresponds to cyrpus 2011 elections, which is included in cyprus_2014. Copy paste below. 
		replace govt = . if country==40 & year==2019
		replace govt = 1 if country==40 & year==2019 & party=="DISY"
		replace govt = 1 if country==40 & year==2019 & party=="DIKO"
		replace vote = . if country==40 & year==2019
		replace vote = 34.3 if country==40 & year==2019 & party=="DISY"
		replace vote = 15.8 if country==40 & year==2019 & party=="DIKO"
		
		replace lrgen = . if country==40 & year==2019 
		replace lrecon = . if country==40 & year==2019 
		replace galtan = . if country==40 & year==2019 
		replace spendvtax = . if country==40 & year==2019 
		replace deregulation = . if country==40 & year==2019 
		replace redistribution = . if country==40 & year==2019 
		replace econ_interven = . if country==40 & year==2019 
		replace civlib_laworder = . if country==40 & year==2019 
		replace sociallifestyle = . if country==40 & year==2019
		replace immigrate_policy = . if country==40 & year==2019 
		replace environment = . if country==40 & year==2019
		replace eu_position = . if country==40 & year==2019 
		
		replace lrgen = 7.5 if country==40 & year==2019 & party=="DISY"
		replace lrecon = 8.5 if country==40 & year==2019 & party=="DISY"
		replace galtan = 6 if country==40 & year==2019 & party=="DISY"
		replace spendvtax = 7 if country==40 & year==2019 & party=="DISY"
		replace deregulation = 9.5 if country==40 & year==2019 & party=="DISY"
		replace redistribution = 8.5 if country==40 & year==2019 & party=="DISY"
		replace econ_interven = 7 if country==40 & year==2019 & party=="DISY"
		replace civlib_laworder = 7 if country==40 & year==2019 & party=="DISY"
		replace sociallifestyle = 4 if country==40 & year==2019 & party=="DISY"
		replace immigrate_policy = 6.5 if country==40 & year==2019 & party=="DISY"
		replace environment = 7 if country==40 & year==2019 & party=="DISY"
		replace eu_position = 6.75 if country==40 & year==2019 & party=="DISY"

		
		replace lrgen = 6 if country==40 & year==2019 & party=="DIKO"
		replace lrecon = 6.25 if country==40 & year==2019 & party=="DIKO"
		replace galtan = 6.25 if country==40 & year==2019 & party=="DIKO"
		replace spendvtax = 6.5 if country==40 & year==2019 & party=="DIKO"
		replace deregulation = 7 if country==40 & year==2019 & party=="DIKO"
		replace redistribution = 6 if country==40 & year==2019 & party=="DIKO"
		replace econ_interven = 5.5 if country==40 & year==2019 & party=="DIKO"
		replace civlib_laworder = 7 if country==40 & year==2019 & party=="DIKO"
		replace sociallifestyle = 5 if country==40 & year==2019 & party=="DIKO"
		replace immigrate_policy = 7 if country==40 & year==2019 & party=="DIKO"
		replace environment = 5 if country==40 & year==2019 & party=="DIKO"
		replace eu_position = 5.5 if country==40 & year==2019 & party=="DIKO"
		
/*notes

------------------------------------------------------------------------------------------------------------
Greek 2015: 

They held two elections, both of which produced the Syriza government (left-wing), who fell short of a couple of seats for majority. In the second election, they got support from independent greeks who is right-wing and received about 3 percent of votes. 

if party=="SYRIZA" & year==2014

------------------------------------------------------------------------------------------------------------

Spain 2016: 

This is a follow up election to 2015 December election. 
A caretaker government was in place until a coalition was formed. AP-P (Alianza-Partido Popular), i assign PP (right-wing) as the government party, but then vote of no confidence leads to PSOE (left-wing) government in 2018. I will code PSOE as the government party, as it was the case before the t-1 turnout. 

if party=="PSOE" & year==2014

------------------------------------------------------------------------------------------------------------

UK 2015: 

Conservative Party as single-party government 

if party=="CONS" & year==2014
------------------------------------------------------------------------------------------------------------

Portugal 2015

PS - social party as a minority government 

if party=="PS" & year==2014
------------------------------------------------------------------------------------------------------------

Finland 2015 

conservative coalition: 1) Centre Party 2) National Coalition Party 3)Blue Reform 

if party=="PS" & year==2014

------------------------------------------------------------------------------------------------------------

Estonia 2015:

1) A coalition of 1) Social Democrats, 2)Pro Patria and 3) Res Publica Union (IRL)

------------------------------------------------------------------------------------------------------------

Poland 2015:

Pis (law and justice)

------------------------------------------------------------------------------------------------------------

Croatia 2007:

Right-wing coalition led by HDZ	- Hrvatska demokratska zajednica (Croatian Democratic Union), but the coalition changed three times. They all were right-wing parties except for SDSS-Samostalna demokratska srpska stranka	 (Independent Democratic Serb Party), but this is a very small ethnic party. 


------------------------------------------------------------------------------------------------------------

Malta 2008:

Nationalist Party is in government: centre-right 


------------------------------------------------------------------------------------------------------------

Luxembourg 2009:

left-wight coaition between CSV (Chrëschtlech Sozial Vollekspartei-Christian Social People's Party) and LSAP (Lëtzebuerger Sozialistesch Aarbechterpartei-Luxembourg Socialist Workers' Party)

------------------------------------------------------------------------------------------------------------

cyprus 2006:

coalition between left-wing and centrist parties. AKEL-Anorthotikó Kómma Ergazómenou Laoú (Progressive Party of Working People) very left wing and the big partner. Centrist partner is DIKO-Dimokratikó Kómma-Democratic Party


------------------------------------------------------------------------------------------------------------
*/

cd "${data}"

keep if governmentparties_t1!="" 
*northern ireland is not included in CHES 
keep if govt==1  // if the party is part of government 
save "government.dta",replace


use "government.dta", clear 

*reverse the scale for EU POSITION so 1 is pro europe. 	
gen eu_position_ = 8 - eu_position
drop eu_position
rename eu_position_ eu_position

sort governmentparties_t1

foreach var of varlist lrgen lrecon galtan spendvtax deregulation redistribution econ_interven sociallifestyle civlib_laworder immigrate_policy environment eu_position {
	gen weighted_`var' = vote * `var'
	bysort governmentparties_t1: egen sum_weighted_`var' = sum(weighted_`var')
    bysort governmentparties_t1: egen sum_voteshare = sum(vote)
	drop weighted_`var'
	gen w_`var' = sum_weighted_`var' / sum_voteshare
	drop sum_weighted_`var' sum_voteshare
}


replace w_econ_interven = . if econ_interven==.
replace w_lrgen = . if lrgen==.
replace w_galtan = . if galtan==.
replace w_spendvtax = . if spendvtax==.
replace w_deregulation = . if deregulation==.
replace w_redistribution = . if redistribution==.
replace w_sociallifestyle = . if sociallifestyle==.
replace w_civlib_laworder = . if civlib_laworder==.
replace w_immigrate_policy = . if immigrate_policy==.
replace w_environment = . if environment==.
replace w_eu_position = . if eu_position==.


keep w_lrgen w_lrecon w_galtan w_spendvtax w_deregulation w_redistribution w_econ_interven w_sociallifestyle w_civlib_laworder w_immigrate_policy w_environment w_eu_position governmentparties_t1



duplicates drop 
rename governmentparties_t1 country_year

save "government_coded.dta", replace 



cd "${data}"
use"dataset.dta", clear 

merge m:1 country_year using "government_coded.dta"

 
drop if country_year==""
drop if country==.

drop _merge 

replace w_lrgen = round(w_lrgen, 1)
replace w_lrecon = round(w_lrecon, 1)
replace w_galtan = round(w_galtan, 1)
replace w_spendvtax = round(w_spendvtax, 1)
replace w_deregulation = round(w_deregulation, 1)
replace w_redistribution = round(w_redistribution, 1)
replace w_econ_interven = round(w_econ_interven, 1)
replace w_sociallifestyle = round(w_sociallifestyle, 1)
replace w_civlib_laworder = round(w_civlib_laworder, 1)
replace w_immigrate_policy = round(w_immigrate_policy, 1)
replace w_environment = round(w_environment, 1)
replace w_immigrate_policy = round(w_immigrate_policy, 1)
replace w_eu_position = round(w_eu_position, 1)


*TABLE L.1: DO VOTERS AND NON-VOTERS DIFFER IN TERMS OF POLICY OPINIONS? (CONTROLLING FOR OUTGOING GOVERNMENT IDEOLOGY)


eststo m1: mixed selfplacement i.voted w_lrgen || country_year_: voted
eststo m2: mixed redistribution i.voted w_lrecon || country_year_: voted
eststo m3: mixed regulation i.voted w_lrecon || country_year_: voted
eststo m4: mixed spending i.voted w_lrecon || country_year_: voted
eststo m5: mixed samesexmarriage i.voted w_galtan || country_year_: voted
eststo m6: mixed immigration i.voted w_galtan || country_year_: voted
eststo m7: mixed environment i.voted w_galtan || country_year_: voted
eststo m8: mixed laworder i.voted w_galtan || country_year_: voted
eststo m9: mixed euintegration i.voted w_eu_position || country_year_: voted

 
 esttab m1 m2 m3 m4 m5 m6 m7 m8 m9 using ${tables}/governmentideologycontrol.tex, replace ///
 b(3) se(3) nogap transform(ln*: exp(2*@) 2*exp(2*@)) ///
 collabels("left-right" "redistribution" "regulation" "spending" "same sex marriage" "immigration" "environment" "civil liberties" "EU integration") ///
 coeflabels(intercept "label of intercept") ///
 title("Regression Results") 
 
 
 
 *BELOW CODE PRODUCES TABLE L.2. AND FIGURE L.1
 

eststo m1_: mixed selfplacement i.voted##c.w_lrgen || country_year: voted
margins, dydx(voted) at(w_lrgen=(0(1)10))
marginsplot, ciopts(color(gs2%50)) plot1opts(msymbol(hollow_circle) mcolor(gs5%50) msize(tiny)) ylabel(,nogrid) xlabel(,nogrid) addplot(hist w_lrgen, percent color(gs10%70) yaxis(2) ytitle("", size(2) axis(2)) yscale(range(0(5)75) axis(2) alt)) yline(0, lcolor(black) lpattern(shortdash)) ytitle("") title("left-right") xtitle("", size(small)) legend(off)
graph save "${data}/government_ideology/lr_government_t1.gph", replace 

*---------------------------------

eststo m2_: mixed redistribution i.voted##c.w_lrecon || country_year: voted
margins, dydx(voted) at(w_lrecon=(0(1)10))
 marginsplot, ciopts(color(gs2%50)) plot1opts(msymbol(hollow_circle) mcolor(gs5%50) msize(tiny)) ylabel(,nogrid) xlabel(,nogrid) addplot(hist w_lrecon, percent color(gs10%70) yaxis(2) ytitle("", size(2) axis(2)) yscale(range(0(5)75) axis(2) alt)) yline(0, lcolor(black) lpattern(shortdash)) ytitle("") title("redistribution") xtitle("", size(small)) legend(off)
 graph save "${data}/government_ideology/redistibution_government_t1.gph", replace 

 
*---------------------------------

eststo m4_: mixed spending i.voted##c.w_lrecon || country_year: voted
margins, dydx(voted) at(w_lrecon=(0(1)10))
 marginsplot, ciopts(color(gs2%50)) plot1opts(msymbol(hollow_circle) mcolor(gs5%50) msize(tiny)) ylabel(,nogrid) xlabel(,nogrid) addplot(hist w_lrecon, percent color(gs10%70) yaxis(2) ytitle("", size(2) axis(2)) yscale(range(0(5)75) axis(2) alt)) yline(0, lcolor(black) lpattern(shortdash)) ytitle("") title("spending") xtitle("", size(small)) legend(off)
graph save "${data}/government_ideology/spending_government_t1.gph", replace 

 
*---------------------------------
 
 
eststo m3_: mixed regulation i.voted##c.w_lrecon || country_year: voted
margins, dydx(voted) at(w_lrecon=(0(1)10))
 marginsplot, ciopts(color(gs2%50)) plot1opts(msymbol(hollow_circle) mcolor(gs5%50) msize(tiny)) ylabel(,nogrid) xlabel(,nogrid) addplot(hist w_lrecon, percent color(gs10%70) yaxis(2) ytitle("", size(2) axis(2)) yscale(range(0(5)75) axis(2) alt)) yline(0, lcolor(black) lpattern(shortdash)) ytitle("") title("regulation") xtitle("", size(small)) legend(off)
graph save "${data}/government_ideology/regulation_government_t1.gph", replace 


 
  *---------------------------------
  
 
eststo m5_: mixed samesexmarriage i.voted##c.w_galtan || country_year: voted
margins, dydx(voted) at(w_galtan=(0(1)10))
marginsplot, ciopts(color(gs2%50)) plot1opts(msymbol(hollow_circle) mcolor(gs5%50) msize(tiny)) ylabel(,nogrid) xlabel(,nogrid) addplot(hist w_galtan, percent color(gs10%70) yaxis(2) ytitle("", size(2) axis(2)) yscale(range(0(5)75) axis(2) alt)) yline(0, lcolor(black) lpattern(shortdash)) ytitle("") title("same-sex marriage") xtitle("", size(small)) legend(off)
graph save "${data}/government_ideology/samesex_government_t1.gph", replace 
 
 
   *---------------------------------
  
  
eststo m6_: mixed immigration i.voted##c.w_galtan || country_year: voted
margins, dydx(voted) at(w_galtan=(0(1)10))
marginsplot, ciopts(color(gs2%50)) plot1opts(msymbol(hollow_circle) mcolor(gs5%50) msize(tiny)) ylabel(,nogrid) xlabel(,nogrid) addplot(hist w_galtan, percent color(gs10%70) yaxis(2) ytitle("", size(2) axis(2)) yscale(range(0(5)75) axis(2) alt)) yline(0, lcolor(black) lpattern(shortdash)) ytitle("") title("immigration") xtitle("", size(small)) legend(off)
 
 graph save "${data}/government_ideology/immigration_government_t1.gph", replace 

    *---------------------------------

eststo m7_: mixed environment i.voted##c.w_lrecon || country_year: voted
margins, dydx(voted) at(w_lrecon=(0(1)10))
marginsplot, ciopts(color(gs2%50)) plot1opts(msymbol(hollow_circle) mcolor(gs5%50) msize(tiny)) ylabel(,nogrid) xlabel(,nogrid) addplot(hist w_lrecon, percent color(gs10%70) yaxis(2) ytitle("", size(2) axis(2)) yscale(range(0(5)75) axis(2) alt)) yline(0, lcolor(black) lpattern(shortdash)) ytitle("") title("environment") xtitle("", size(small)) legend(off)
 graph save "${data}/government_ideology/environment_government_t1.gph", replace 

   *---------------------------------
   
eststo m8_: mixed laworder i.voted##c.w_galtan || country_year: voted
margins, dydx(voted) at(w_galtan=(0(1)10))
marginsplot, ciopts(color(gs2%50)) plot1opts(msymbol(hollow_circle) mcolor(gs5%50) msize(tiny)) ylabel(,nogrid) xlabel(,nogrid) addplot(hist w_galtan, percent color(gs10%70) yaxis(2) ytitle("", size(2) axis(2)) yscale(range(0(5)75) axis(2) alt)) yline(0, lcolor(black) lpattern(shortdash)) ytitle("") title("civil liberties") xtitle("", size(small)) legend(off)
  graph save "${data}/government_ideology/laworder_government_t1.gph", replace 

    *---------------------------------
	
eststo m9_: mixed euintegration i.voted##c.w_eu_position || country_year: voted
margins, dydx(voted) at(w_eu_position=(1(1)7))
marginsplot, ciopts(color(gs2%50)) plot1opts(msymbol(hollow_circle) mcolor(gs5%50) msize(tiny)) ylabel(,nogrid) xlabel(,nogrid) addplot(hist w_eu_position, percent color(gs10%70) yaxis(2) ytitle("", size(2) axis(2)) yscale(range(0(5)100) axis(2) alt)) yline(0, lcolor(black) lpattern(shortdash)) ytitle("") title("EU integration") xtitle("", size(small)) legend(off) 
 graph save "${data}/government_ideology/eu_government_t1.gph", replace 

 
 * TABLE L.2: TESTING (DE)MOBILIZATION EFFECT OF PREVIOUS GOVERNMENT IDEOLOGY
 
 
  esttab m1_ m2_ m3_ m4_ m5_ m6_ m7_ m8_ m9_ using ${tables}/governmentideologyinteraction.tex, replace ///
 b(3) se(3) nogap transform(ln*: exp(2*@) 2*exp(2*@)) ///
 collabels("left-right" "redistribution" "regulation" "spending" "same sex marriage" "immigration" "environment" "civil liberties" "EU integration") ///
 coeflabels(intercept "label of intercept") ///
 title("Regression Results") 
 
 

 * FIGURE L.1: MOBILIZING AND DEMOBILIZING EFFECTS OF OUTGOING GOVERNMENT IDEOLOGY
cd "${data}/government_ideology"
graph combine lr_government_t1.gph redistibution_government_t1.gph spending_government_t1.gph regulation_government_t1.gph environment_government_t1.gph samesex_government_t1.gph immigration_government_t1.gph laworder_government_t1.gph eu_government_t1.gph, ycommon xsize(10) ysize(7)
graph save "${figures}/combinedgovernment_t1.gph", replace 
graph export "${figures}/combinedgovernment_t1.png", as(png) replace
